<template>
  <div>
    <div class="draw" v-if="loadState == false">
      <img
        class="loading"
        src="../assets/loading/Fg7PS0IesulBHFZwCvfx9-pj6fgs.gif"
        alt=""
      />
    </div>
    <div class="draw" v-if="loadState == true">
      <div class="draw-list" v-for="(de, di) in moviesData.list" @click="jumpDetail(de.id)" :key="di">
        <div class="list">
          <!-- <img :src="`${de.img}`" alt="" /> -->
          <img v-lazy="de.img" alt="" :key="de.img" />
          <div class="txt">
            <!-- 上 -->
            <div class="txt-top">
              <div class="txt-top-1">
                <p class="top-p1">{{ de.nm }}</p>
                <p class="top-p2">{{ de.wish }}人想看</p>
              </div>
              <span class="txt-top-2">{{ de.enm }}</span>
            </div>
            <!-- 中 -->
            <div class="txt-center">
              <p class="center-p1">
                <span class="center-s1">电影</span>
                {{ de.cat }}
              </p>
              <p
                class="center-p2"
                :style="`${
                  de.hasOwnProperty('showStateButton')
                    ? 'background:#3C9FE6'
                    : 'background:#faaf01'
                }`"
              >
                {{
                  de.hasOwnProperty("showStateButton") == true ? "预售" : "想看"
                }}
              </p>
            </div>
            <!-- 下 -->
            <div class="txt-bottom">
              <p>{{ de.act }}</p>
              <p>{{ de.pubDesc }}</p>
              <!-- <p>{{de.hasOwnProperty('showStateButton')}}</p> -->
            </div>
          </div>
        </div>
      </div>
      <p class="draw-p">
        查看全部{{ moviesData.total }}部相关影视综作品
        <i class="iconfont icon-xiangyou1"></i>
      </p>
    </div>
    <!-- 组件 -->
    <search-txt v-bind:movedata="cinemasData"></search-txt>
  </div>
</template>
<script>
import searchTxt from "../components/comp-searchtxt.vue";
export default {
  name: "cartAll",
  props: ["msg"],
  data() {
    return {
      moviesData: [], //搜索到的数据
      cinemasData: [], //搜索到的数据  影院
      v1: "",
      loadState: -1, //loading状态
    };
  },
  components: {
    searchTxt,
  },
  methods: {
    getData() {
      this.loadState = false;
      let pro = axios.get("search/suggest", {
        params: {
          kw: this.msg,
          cityId: 1,
        },
      });
      pro
        .then((res) => {
          setTimeout(() => {
            this.loadState = true;
            this.moviesData = res.movies;
            this.cinemasData = res.cinemas;
            console.log(this.msg);
          }, 1000);
          console.log("请求成功----->", res);
        })
        .catch((err) => {
          console.log("请求失败----->", err);
        });
    },
    jumpDetail(k) {
      console.log(k);
      this.$router.push({ path: "/detail", query: { id: k } });
    },
  },
  watch: {
    msg(value) {
      console.log("----", value);
      this.getData();
    },
  },
  //   mounted() {},
};
</script>

<style lang="scss" scoped>
// 渲染数据
.draw {
  .loading {
    width: 100%;
  }
  .draw-list {
    width: 100%;
    background: rgb(248, 248, 248);
    .list {
      width: 352px;
      margin: 14px auto;
      padding: 7px 0;

      display: flex;
      justify-content: space-between;
      img {
        width: 80px;
        height: 110px;
        border-radius: 6px;
        object-fit: cover;
      }
      // 文本区
      .txt {
        width: 255px;
        // 上
        .txt-top {
          width: 100%;
          height: 40px;
          display: flex;
          flex-direction: column;
          justify-content: space-between;
          align-content: flex-start;
          .txt-top-1 {
            display: flex;
            justify-content: space-between;
            .top-p1 {
              font-size: 16px;
              color: #000;
              font-weight: bold;
            }
            .top-p2 {
              font-size: 14px;
              color: #ffa82e;
            }
          }
          .txt-top-2 {
            display: inline-block;
            font-size: 12px;
            flex-wrap: 300;
          }
        }
        // 中
        .txt-center {
          margin: 3px 0;
          display: flex;
          justify-content: space-between;
          align-items: center;
          .center-p1 {
            font-size: 14px;
            .center-s1 {
              font-size: 10px;
              box-sizing: border-box;
              color: #67a6ff !important;
              border-radius: 3px;
              border: 1px solid #85a9da !important;
            }
          }
          .center-p2 {
            padding: 6px 14px;
            border-radius: 18px;
            font-size: 14px;
            background: #faaf00;
            color: rgb(245, 245, 245);
          }
        }

        // 下
        .txt-bottom {
          p {
            font-size: 10px;
            padding: 3px 0;
          }
        }
      }
    }
  }
  .draw-list:first-child {
    //  margin: 0 auto 14px;
  }
  .draw-p {
    background: rgb(248, 248, 248);
    font-size: 16px;
    color: #f34c40;
    // padding: 1px 0;
    width: 100%;
    height: 50px;
    text-align: center;
    line-height: 50px;
  }
}
</style>